package com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels;

import android.app.PendingIntent;
import android.content.Context;

import com.nickstumpos.android.GmailWidgetPlus.Constants.GMWP_Constants;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.AWidgetUIManager;

public abstract class AWidgetWithUnreadCountUIManager extends AWidgetUIManager {

	private final int	unreadCountButton;

	public AWidgetWithUnreadCountUIManager(final Context context,
			final String account,
			final int widgetid,
			final int unreadCountButton) {
		super(context, account, widgetid);
		this.unreadCountButton = unreadCountButton;
	}

	protected void hideUnreadButton() {
		this.hideView(this.unreadCountButton);
	}

	protected void initUnreadButtonIntent() {
		final PendingIntent openGmailToUnread = this.getGMWPIntents()
				.openGmailSearchIntent(GMWP_Constants.GMAIL_UNREAD_QUERY);
		this.setClickAction(this.unreadCountButton, openGmailToUnread);
	}

	protected void showUnreadButton() {
		this.hideView(this.unreadCountButton);
	}

	protected void updateUnreadCount(final int unreadCount) {
		this.setViewText(this.unreadCountButton, String.valueOf(unreadCount));
	}
}
